package com.wandian.util;

/**
 * 管理游戏内共享数据
 * 
 * @author long
 * @Create 2012-10-6 下午1:35:58
 * @QQ 108232706
 * @version 1.0
 * @description GameDataUtil
 */
public class GameDataUtil {

	private static volatile int onlineCount;
	private final static Object onlineLock = new Object();

	public static int getOnlineCount() {
		synchronized (onlineLock) {
			return onlineCount;
		}

	}

	public static void setOnlineCount(int onlineCount) {
		synchronized (onlineLock) {
			GameDataUtil.onlineCount = onlineCount;
		}
	}

	/**
	 * +新来用户，-离开
	 * 
	 * @param _onlineCount
	 */
	public static int setUserOpenClose(int _onlineCount) {
		synchronized (onlineLock) {
			return GameDataUtil.onlineCount += _onlineCount;
		}
	}
}
